# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer:
pkgname=catch2-3
pkgver=3.7.1
pkgrel=0
arch="all"
url="https://github.com/catchorg/Catch2"
pkgdesc="Modern, C++-native, header-only, test framework for unit-tests (v3)"
license="BSL-1.0"
makedepends="
	cmake
	python3
	samurai
	"
source="https://github.com/catchorg/Catch2/archive/v$pkgver/catch2-v$pkgver.tar.gz"
subpackages="$pkgname-doc"
builddir="$srcdir/Catch2-$pkgver"

build() {
	# Set -DCATCH_DEVELOPMENT_BUILD to enable tests
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCATCH_DEVELOPMENT_BUILD="$(want_check && echo ON || echo OFF)" \
		-DCATCH_BUILD_EXTRA_TESTS="$(want_check && echo ON || echo OFF)" \
		-DCATCH_ENABLE_WERROR=OFF
	cmake --build build
}

check() {
	# ApprovalTests is broken https://github.com/catchorg/Catch2/issues/1780
	ctest --output-on-failure --test-dir build -E "ApprovalTests"
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
e04c676e6bb3d7791f51a1caa770c4675d79b5396c9ba029c01ca0938e53bfa374dce117fccf753a89f3663192c91356acc9bc195e4866d215855df0667faff0  catch2-v3.7.1.tar.gz
"
